//
//  HomeCell.m
//  CMJWeibo
//
//  Created by BH on 16/1/4.
//
//

#import "HomeCell.h"
#import "StatusFrame.h"
#import "StatusToolBar.h"
#import "StatusTopView.h"

@interface HomeCell ()
//cell上部分view，即显示内容view
@property(nonatomic,strong)StatusTopView *topView;
//cell的工具栏，即3个按钮
@property(nonatomic,strong)StatusToolBar *toolBar;

@end

@implementation HomeCell

+(instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"HomeCell";
    HomeCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[HomeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }else{
        for (UIView *subview in cell.contentView.subviews) {
            [subview removeFromSuperview];
        }
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
        //添加上部分view
        StatusTopView *topV = [[StatusTopView alloc] init];
        [self addSubview:topV];
        self.topView = topV;
        //添加底部按钮栏
        StatusToolBar *toolB = [[StatusToolBar alloc] init];
        [self addSubview:toolB];
        self.toolBar = toolB;
    }
    return self;
}

-(void)setStatusF:(StatusFrame *)statusF
{
    _statusF = statusF;
    
    self.topView.statusF = statusF;
    
    self.toolBar.frame = statusF.toolbarF;
    self.toolBar.statusM = statusF.status;
}

@end
